package SoftwareEngineering01;

import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int max_Sum = 0;
        Integer [] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = i; j < n; j++) {
                sum += a[j];
                if(sum >= max_Sum){
                    max_Sum = sum;
                }
            }
        }
        System.out.println(max_Sum);
    }
}
